local youdi = fk.CreateSkill{
    name = "lingling__youdi"
}
Fk:loadTranslationTable{
    ["lingling__youdi"] = "诱敌",
    [":lingling__youdi"] = "当其他角色使用【杀】指定你为目标后，或当你使用【杀】指定其他角色为目标后，你可以令对方摸两张牌，则造成伤害后你获得对方两张手牌。",
    ["#lingling__youdi-invoke"] = "是否发动 诱敌，令 %dest 摸两张牌？",
    ["#lingling__youdi"] = "诱敌：获得 %dest 两张牌",
}

youdi:addEffect(fk.TargetSpecified,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(youdi.name) and data.card.trueName == "slash" and data.to ~= player
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player,{
            skill_name = youdi.name,
            prompt = "#lingling__youdi-invoke::"..data.to.id
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        data.extra_data = data.extra_data or {}
        data.extra_data.lingling__youdi = data.extra_data.lingling__youdi or {}
        data.extra_data.lingling__youdi[tostring(player.id)] = data.extra_data.lingling__youdi[tostring(player.id)] or {}
        table.insertIfNeed(data.extra_data.lingling__youdi[tostring(player.id)], data.to.id)
        data.to:drawCards(2, youdi.name)
    end,
})

youdi:addEffect(fk.TargetConfirmed,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(youdi.name) and data.card.trueName == "slash" and data.from ~= player
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player,{
            skill_name = youdi.name,
            prompt = "#lingling__youdi-invoke::"..data.from.id
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        data.extra_data = data.extra_data or {}
        data.extra_data.lingling__youdi = data.extra_data.lingling__youdi or {}
        data.extra_data.lingling__youdi[tostring(player.id)] = data.extra_data.lingling__youdi[tostring(player.id)] or {}
        table.insertIfNeed(data.extra_data.lingling__youdi[tostring(player.id)], data.from.id)
        data.from:drawCards(2, youdi.name)
    end,
})

youdi:addEffect(fk.Damage, {
    is_delay_effect = true,
    mute = true,
    can_trigger = function(self, event, target, player, data)
        local current = target == player and data.to or data.from
        if data.card and current and not current.dead and not current:isNude() then
            local parentUseData = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
            if parentUseData then
                local cardUseEvent = parentUseData.data
                return cardUseEvent.extra_data and cardUseEvent.extra_data.lingling__youdi and cardUseEvent.extra_data.lingling__youdi[tostring(player.id)] and table.contains(cardUseEvent.extra_data.lingling__youdi[tostring(player.id)], current.id)
            end
        end
    end,
    on_cost = function (self, event, target, player, data)
        local current = target == player and data.to or data.from
        local cards = current:getCardIds("h")
        if #cards > 2 then
            cards = player.room:askToChooseCards(player,{
                target = current,
                flag = "h",
                max = 2,
                min = 2,
                skill_name = youdi.name,
                prompt = "#lingling__youdi::"..current.id
            })
        end
        if #cards > 0 then
            event:setCostData(self, {cards = cards})
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        player.room:obtainCard(player, event:getCostData(self).cards, false, fk.ReasonJustMove, player, youdi.name)
    end,
})

return youdi